package 力扣.双指针.最长区间;

public class 乘积小于k的子数组713 {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
         if (nums == null || nums.length == 0){
             return 0;
         }
         int left = -1;
         int ans = 0;
         int p = 1;
        for (int i = 0; i < nums.length; i++) {
            int t = nums[i];
            p *= t;
            while (p >= k && left < i){
                p /= nums[++left];
            }
//            left--;
/*            int A = i - left;//求阶乘
            for (int j = 1; j <= A; j++) {
                ans += j;
            }*/
            ans += i - left;
        }
        return ans;
    }
}
